package com.example.zhu29.bledemo.util;

/**
   * Created by zhudewei on 2016/1/24.
   * Constant tool class
   */
public class ZConstTool {

    /******************** Store related constants ********************/
    public static final String CRASHSD = "crash/crash";
    /**
           * Multiples of Byte and Byte
           */
    public static final int BYTE = 1;
    /**
           * Multiples of KB and Byte
           */
    public static final int KB = 1024;
    /**
           * Multiples of MB and Byte
           */
    public static final int MB = 1048576;
    /**
           * Multiples of GB and Byte
           */
    public static final int GB = 1073741824;
    /**
           * Multiples of milliseconds and milliseconds
           */
    public static final int MSEC = 1;

    /******************** Time dependent constant ********************/
    /**
           * multiples of seconds and milliseconds
           */
    public static final int SEC = 1000;
    /**
           * minutes and multiples of milliseconds
           */
    public static final int MIN = 60000;
    /**
           * multiples with milliseconds
           */
    public static final int HOUR = 3600000;
    /**
           * multiples of days and milliseconds
           */
    public static final int DAY = 86400000;
    /**
           * Regular: mobile phone number (simple)
           */
    public static final String REGEX_MOBILE_SIMPLE = "^[1]\\d{10}$";
    /**
           * Regular: mobile phone number (accurate)
           * Move: 134 (0-8), 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 178, 182, 183, 184, 187, 188
           * Unicom: 130, 131, 132, 145, 155, 156, 175, 176, 185, 186
           * Telecommunications: 133, 153, 173, 177, 180, 181, 189
           * Global Star: 1349
           * Virtual Operator: 170
           */
    public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$";

/******************** Regular related constants ********************/

       //-------------------------------------------- Regular expressions - ----------------------------------------
         /**
      * Original link: http://caibaojian.com/regexp-example.html
      * Extract the network link in the message: (h|H)(r|R)(e|E)(f|F) *= *('|")?(\w|\\|\/|\.) +('|"| *|>)?
      * Extract the email address in the message: \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
      * Extract the image link in the message: (s|S)(r|R)(c|C) *= *('|")?(\w|\\|\/|\.)+('|" | *|>)?
      * Extract the IP address in the message: (\d+)\.(\d+)\.(\d+)\.(\d+)
      * Extract the Chinese phone number (including mobile and landline) in the message: (\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}
      * Extract the Chinese postal code in the message: [1-9]{1}(\d+){5}
      * Extract the Chinese ID number in the message: \d{18}|\d{15}
      * Extract the integer in the message: \d+
      * Extract the floating point number (ie decimal) in the message: (-?\d*)\.?\d+
      * Extract any number in the message :(-?\d*)(\.\d+)?
      * Extract the Chinese string in the message: [\u4e00-\u9fa5]*
      * Extract double-byte strings in Chinese characters (Chinese characters): [^\x00-\xff]*
      */
                /**
          * Regular: phone number
          */
    public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
    /**
     * Regular: ID number 15
     */
    public static final String REGEX_IDCARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
    /**
     * Regular: ID number 18
     */
    public static final String REGEX_IDCARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
    /**
     * Regular: ID number 15 or 18 contains end with x
     */
    public static final String REGEX_IDCARD = "(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$|^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|preIntercept|X)$)";
    /**
     * Regular: mailbox
     */
    public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
    /**
     * Regular: URL
     */
    public static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
    /**
     * Regular: Chinese characters
     */
    public static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
    /**
     * Regular: User name, the range of values is a-z, A-Z, 0-9, "_", Chinese characters, can not end with "_", user name must be 6-20
     */
    public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$";
    /**
     * Regular: date verification in yyyy-MM-dd format, has been considered
     */
    public static final String REGEX_DATE = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
    /**
     * Regular: IP address
     */
    public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";

    public enum MemoryUnit {
        BYTE,
        KB,
        MB,
        GB
    }

    public enum TimeUnit {
        MSEC,
        SEC,
        MIN,
        HOUR,
        DAY
    }
}